// Package hello -----------------------------
// @file      : hello.go
// @author    : WuZhouHai
// @contact   : wzh200x@126.com
// @time      : 2024/1/3 19:04
// @desc      :
// -------------------------------------------
package hello

import (
	"context"
	"github.com/gogf/gf/v2/container/garray"
	"github.com/gogf/gf/v2/frame/g"
)

type HelloReq struct {
	g.Meta `path:"/hello" method:"get"`
	Name   string `v:"required" dc:"Your name"`
}
type HelloRes struct {
	Reply *garray.StrArray `json:"result"`
}

type Hello struct{}

func (Hello) HelloHandler(ctx context.Context, req *HelloReq) (res *HelloRes, err error) {
	//g.Log().Debugf(ctx, `receive say: %+v`, req)
	//res = &HelloRes{
	//	Reply: fmt.Sprintf(`Hi %s`, req.Name),
	//}
	//g.RequestFromCtx(ctx).Response.Writeln("Hello World!")
	//_, sqlErr := dao.JlGameDwysUser.Ctx(ctx).Data(do.JlGameDwysUser{
	//	Meta:      g.Meta{},
	//	Uid:       "golang_test001",
	//	Localuuid: "546655",
	//	Platform:  999,
	//	LoginTime: gtime.Now(),
	//	IsMini:    0,
	//	Water:     0,
	//}).Save()
	//_, sqlErr := g.DB().Model("jl_game_dwys_user").Data(g.Map{
	//	"uid":        "golang_test003",
	//	"localuuid":  "546657",
	//	"platform":   999,
	//	"login_time": gtime.Now(),
	//	"is_mini":    0,
	//	"water":      0,
	//}).Save()
	//_, sqlErr := databaseManager.PhoenixManagerDatabase().SaveDataWithMap("default", "jl_game_dwys_user",
	//	g.Map{
	//		"uid":        "golang_test004",
	//		"localuuid":  "546658",
	//		"platform":   999,
	//		"login_time": gtime.Now(),
	//		"is_mini":    0,
	//		"water":      0,
	//	})
	//if sqlErr != nil {
	//	g.Log().Errorf(ctx, `save JlGameDwysUser error: %+v`, sqlErr)
	//}
	//logicConfigManager.PhoenixManagerLogicConfig().GetConfig(defines.Config_CardGroup)
	//re := gameLogic.ChooseCard(1, 10)
	//s := re.String()
	//res = &HelloRes{
	//	Reply: fmt.Sprintf(`%s`, s),
	//}
	//t, _ := moduleManager.PhoenixManagerModule().GetModuleData(39267, 10002)
	//for k, v := range t {
	//	fmt.Printf("%s:%v\n", k, v)
	//}
	//t["1"] = int(t["1"].(float64)) + 100
	//moduleManager.PhoenixManagerModule().UpdateModuleData(39267, 10002, t)
	//params := new(gmap.StrAnyMap)
	//params.Set("chooseCardType", 1)
	//params.Set("chooseCounts", 1)
	//userId := gconv.Uint64(req.Name)
	//re, e := moduleManager.PhoenixManagerModule().DoModuleLogic(defines.ModuleType_Card, defines.ModuleLogic_ChooseCard, userId, params)
	//if e != nil {
	//	logger.PhoenixLoggerIns().Error(e.Error())
	//}
	//reData := base.GetLogicResultData(re)
	//reChoose := reData.Get("logicBack")
	//array := reChoose.(*garray.StrArray)
	//res = &HelloRes{
	//	Reply: array,
	//}
	return
}

func NewHello() interface{} {
	return &Hello{}
}
